/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.ProductInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.config.Config;
/*    */ import com.newcrm.db.CompanyExtManager;
/*    */ import com.newcrm.db.CompanyManager;
/*    */ import com.newcrm.db.UserManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import javax.servlet.RequestDispatcher;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowAddUser extends AbstractAction
/*    */ {
/* 31 */   private static Logger logger = Logger.getLogger(ShowAddUser.class.getName());
/*    */ 
/*    */   public ShowAddUser(AbstractHttpServlet servlet) {
/* 34 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 44 */     if ((!super.getLoginUser(request).isAdmin) && 
/* 45 */       (!super
/* 45 */       .getLoginUser(request).isGroupAdmin)) {
/* 46 */       request.getRequestDispatcher("/nopermission.jsp").forward(
/* 47 */         request, response);
/* 48 */       return;
/*    */     }
/*    */ 
/* 51 */     int companyId = super.getLoginUser(request).companyId;
/* 52 */     CompanyManager manager = new CompanyManager();
/* 53 */     int userNum = manager.getMaxUsersNum(companyId);
/*    */ 
/* 55 */     if (userNum > 0) {
/* 56 */       UserManager userManager = new UserManager();
/* 57 */       int currentUserNum = userManager.getCompanyUsersNum(companyId);
/* 58 */       if (currentUserNum >= userNum) {
/* 59 */         request.setAttribute("licenseUserNum", Integer.valueOf(userNum));
/* 60 */         request.setAttribute("currentUserNum", Integer.valueOf(currentUserNum));
/* 61 */         request.getRequestDispatcher("/licenseerrorpage.jsp").forward(
/* 62 */           request, response);
/* 63 */         return;
/*    */       }
/*    */     }
/*    */ 
/* 67 */     ProductInfo productInfo = Config.getInstance().productInfo;
/* 68 */     UserManager userManager = new UserManager();
/*    */ 
/* 70 */     if ("1".equals(productInfo.activeCodeFlag))
/*    */     {
/* 72 */       int currentUserNum = userManager.getCompanyUsersNum(companyId);
/* 73 */       CompanyExtManager companyExtManager = new CompanyExtManager();
/* 74 */       String licenceNum = companyExtManager.getFieldValue(companyId, 
/* 75 */         17);
/*    */ 
/* 77 */       if (currentUserNum >= Integer.parseInt(licenceNum)) {
/* 78 */         logger.warn("userNum >= licenceNum, userNum: " + licenceNum + 
/* 79 */           " / licenceNum: " + licenceNum);
/* 80 */         request.setAttribute("licenseUserNum", licenceNum);
/* 81 */         request.setAttribute("currentUserNum", Integer.valueOf(currentUserNum));
/* 82 */         request.getRequestDispatcher("/licenseerrorpage.jsp").forward(
/* 83 */           request, response);
/* 84 */         return;
/*    */       }
/*    */     }
/*    */ 
/* 88 */     int groupId = Util.getURLIntParameter(request.getParameter("groupId"));
/* 89 */     request.setAttribute("groupId", Integer.valueOf(groupId));
/* 90 */     request.getRequestDispatcher("/profiles_new.jsp").forward(request, 
/* 91 */       response);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowAddUser
 * JD-Core Version:    0.6.1
 */